using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Framework.Module.CMS.Library;
using Framework.Library.Utilities;
using Framework.Library;
using Framework.Module.CMS.Library.Zones;

namespace Framework.Module.CMS.Web.HomePage
{
    public partial class LeftMenu : CMSWebControl
    {
        public DataTable dt = null;
        public DataTable dt1 = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            this.dt = ZoneController.GetZonesVisbleInNavbar(ConvertUtility.ToInt32(AppEnv.PortalId()));
            DataListintro.DataSource = dt;
            DataListintro.DataBind();
        }

        protected void OnItemDatabounds(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
        {
            DataRowView row = (DataRowView)e.Item.DataItem;
            HyperLink hplActive = (HyperLink)e.Item.FindControl("hplActive");

            hplActive.NavigateUrl = BuildUrlByZone((ConvertUtility.ToInt32(row["Zone_ID"])), ConvertUtility.ToInt32(row["Portal_TabControlID"]));
            hplActive.Text = Convert.ToString(row["Zone_Name"]);
            Table tblActive = (Table)e.Item.FindControl("tblActive");
            if (Convert.ToInt32(row["Zone_ID"]) != Convert.ToInt32(Request.QueryString["catid"]))
            {
                tblActive.BackImageUrl = "";
                hplActive.CssClass = "text4";
            }
            else
            {
                hplActive.CssClass = "text5";
                hplActive.NavigateUrl = "";
                tblActive.BackImageUrl = "/images/HomePage/bg_tab.jpg";
            }

            Label m_lableID = (Label)e.Item.FindControl("lblID");
            Int32 m_ID = Convert.ToInt32(m_lableID.Text.ToString());
            this.dt1 = ZoneController.GetZones(ConvertUtility.ToInt32(m_ID), AppEnv.PortalId());

            DataList SqlDataS = (DataList)e.Item.FindControl("DataListItem");
            SqlDataS.DataSource = dt1;
            SqlDataS.ItemDataBound += new DataListItemEventHandler(SqlDataS_ItemDataBound);
            SqlDataS.DataBind();

        }
        private void SqlDataS_ItemDataBound(object o, DataListItemEventArgs e)
        {
            DataRowView row = (DataRowView)e.Item.DataItem;
            HyperLink hplActive = (HyperLink)e.Item.FindControl("hplActive1");
            Table tblActive = (Table)e.Item.FindControl("tblActive1");
            hplActive.NavigateUrl = BuildUrlByZone((ConvertUtility.ToInt32(row["Zone_ID"])), ConvertUtility.ToInt32(row["Portal_TabControlID"]));
            hplActive.Text = Convert.ToString(row["Zone_Name"]);
            if (Convert.ToInt32(row["Zone_ID"]) != Convert.ToInt32(Request.QueryString["catid"]))
            {
                hplActive.CssClass = "text4";
            }
            else
            {
                hplActive.CssClass = "text5";
                hplActive.NavigateUrl = "";
                tblActive.BackImageUrl = "/images/HomePage/bg_tab.jpg";
            }
        }
    }
}